import { Renderer } from "../engine";
import { Behaviour } from "./Behaviour";
import { Rectangle } from "./math";
import { boolean } from "./validators/boolean";
import { string } from "./validators/string";

export class BitmapWithClipRender extends Behaviour implements Renderer{
    @string()
    source = "";

    //IsClear=false
    clip:{x:number,y:number,width:number,height:number,IsClear:boolean}={x:0,y:0,width:0,height:0 ,IsClear:false}
    
    clips:{x:number,y:number,width:number,height:number}[] = []

    onStart(){
        this.clip={ x:0,y:0,width:0,height:0,IsClear:false }
    }
    onUpdate(){

        this.clip={ x:this.clip.x,y:this.clip.y,width:this.clip.width,height:this.clip.height,IsClear:this.clip.IsClear}
    }

    getBounds(): Rectangle {
        const img = this.engine.resourceManager.getImage(this.source)
        return {
            x: 0,
            y: 0,
            width: img.width,
            height: img.height,
        };
    }
}